/*
 * WebEntryData.java
 * 
 * Created on 2007-12-17, 17:29:08
 * 
 */

package com.gln.bloger.pojos;

import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

/**
 * 
 * @author renxj
 */
@Searchable(alias = "Entry")
public class Entry extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@SearchableId
	private String id;

	@SearchableProperty
	private String title;

	@SearchableProperty
	private String content;

	@SearchableProperty(format = "yyyy-mm-dd")
	private Date dateCreated;

	private Website website;

	private User author;

	@SearchableProperty
	private String summary;

	private int commentSize;

	private int hits;

	private String postIP;

	private Category category;

	private String status;

	private Set<Tag> tags = new HashSet<Tag>();

	private Date dateModified;

	public Date getDateModified() {
		return dateModified;
	}

	public void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Website getWebsite() {
		return website;
	}

	public void setWebsite(Website website) {
		this.website = website;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public int getCommentSize() {
		return commentSize;
	}

	public void setCommentSize(int commentSize) {
		this.commentSize = commentSize;
	}

	public int getHits() {
		return hits;
	}

	public void setHits(int hits) {
		this.hits = hits;
	}

	public Set<Tag> getTags() {
		return tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@Override
	public void setData(Entity other) {
		Entry otherEntry = (Entry) other;
		this.author = otherEntry.getAuthor();
		this.commentSize = otherEntry.getCommentSize();
		this.content = otherEntry.getContent();
		this.dateCreated = otherEntry.getDateCreated();
		this.hits = otherEntry.getHits();
		this.id = otherEntry.getId();
		this.summary = otherEntry.getSummary();
		this.tags = otherEntry.getTags();
		this.title = otherEntry.getTitle();
		this.website = otherEntry.getWebsite();
	}

	public static final class CommentStatus {
		private CommentStatus() {
		}

		/**
		 * The entry is open for comment.<br />
		 * <code><strong>open</strong></code>
		 */
		public static final String OPEN = "open";

		/**
		 * The entry is not allowed comment.<br />
		 * <code><strong>close</strong></code>
		 */
		public static final String CLOSE = "close";

		/**
		 * The entry is commented by registered user only.<br />
		 * <code><strong>registered_only</strong></code>
		 */
		public static final String REGISTERED_ONLY = "registered_only";

		/**
		 * all of the comment status.<br />
		 * <code><strong>open</strong></code>&nbsp;
		 * <code><strong>close</strong></code>&nbsp;
		 * <code><strong>registered_only</strong></code>
		 */
		public static final List<String> COMMENT_STATUS = Arrays
				.asList(new String[] { OPEN, CLOSE, REGISTERED_ONLY });
	}

	public String getPostIP() {
		return postIP;
	}

	public void setPostIP(String postIP) {
		this.postIP = postIP;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
}